<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<body class="hold-transition skin-blue sidebar-mini">
<section class="content-header">
    <h1 th:if="${tittle==1}" th:text="整体外协月入库明细及金额" style="display: inline-block"></h1>
    <h1 th:if="${tittle==1}"  style="display: inline-block">总金额:[[${amount}]]元</h1>
    <h1 th:if="${tittle==2}" style="display: inline-block" th:text="整体外协月出库明细及金额"></h1>
    <h1 th:if="${tittle==2}"  style="display: inline-block">总金额:[[${amount}]]元</h1>
    <h1 th:if="${tittle==3}" style="display: inline-block" th:text="整体外协年度入库明细及金额"></h1>
    <h1 th:if="${tittle==3}"  style="display: inline-block">总金额:[[${amount}]]元</h1>
    <h1 th:if="${tittle==4}" style="display: inline-block" th:text="整体外协年度出库明细及金额"></h1>
    <h1 th:if="${tittle==4}"  style="display: inline-block">总金额:[[${amount}]]元</h1>
    <h1 th:if="${tittle==5}" style="display: inline-block" th:text="铝料月入库明细及金额及吨数"></h1>
    <h1 th:if="${tittle==5}"  style="display: inline-block">总金额:[[${amount}]]元 吨数:[[${weight}]]吨</h1>
    <h1 th:if="${tittle==6}" style="display: inline-block" th:text="铝料月出库明细及金额及吨数"></h1>
    <h1 th:if="${tittle==6}"  style="display: inline-block">总金额:[[${amount}]]元 吨数:[[${weight}]]吨</h1>
    <h1 th:if="${tittle==7}" style="display: inline-block" th:text="铝料年度入库明细及金额及吨数"></h1>
    <h1 th:if="${tittle==7}"  style="display: inline-block">总金额:[[${amount}]]元 吨数:[[${weight}]]吨</h1>
    <h1 th:if="${tittle==8}" style="display: inline-block" th:text="铝料年度出库明细及金额及吨数"></h1>
    <h1 th:if="${tittle==8}"  style="display: inline-block">总金额:[[${amount}]]元 吨数:[[${weight}]]吨</h1>
    <h1 th:if="${tittle==9}" style="display: inline-block" th:text="制作件月入库总表"></h1>
    <h1 th:if="${tittle==10}" style="display: inline-block" th:text="制作件月出库总表"></h1>
    <h1 th:if="${tittle==11}" style="display: inline-block" th:text="制作件年入库总表"></h1>
    <h1 th:if="${tittle==12}" style="display: inline-block" th:text="制作件年出库总表"></h1>
    <h1 th:if="${tittle==13}" style="display: inline-block" th:text="制作件在库项目明细表"></h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <form id="queryForm" action="/half/halWarManage/inAndOutQuery/exportExcel">
                    <div class="box-header">
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group">
                                    <label>物料分类</label>
                                    <select id="ityMatType" name="odaMatType" class="form-control">
                                        <option th:if="${odaMatType==3}" value="3">制作件</option>
                                        <option th:if="${odaMatType==2}" value="2">外协件</option>
                                        <option th:if="${odaMatType==4}" value="4">铝料</option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label>项目编号</label>
                                    <input type="text" id="odaProCode" name="odaProCode"
                                           placeholder="请输入项目编号" class="form-control">
                                </div>
                                <div class="form-group">
                                    <label>项目名称</label>
                                    <input type="text" id="odaProName" name="odaProName"
                                           class="form-control"
                                           placeholder="请输入项目名称">
                                </div>

                                <div class="form-group">
                                    <label>物料描述</label>
                                    <input type="text" id="odaMatName" name="odaMatName"
                                           class="form-control"
                                           placeholder="请输入物料描述">
                                </div>
                                <div class="form-group">
                                    <label>图号</label>
                                    <input type="text" id="odaDrawingCode" name="odaDrawingCode"
                                           class="form-control"
                                           placeholder="请输入图号">
                                </div>
                                <div class="form-group">
                                    <label>SAP物料编码</label>
                                    <input type="text" id="odaSapCode" name="odaSapCode"
                                           class="form-control"
                                           placeholder="请输入SAP物料编码"/>
                                </div>
                                <div class="form-group">
                                    <label>跟踪号</label>
                                    <input type="text" id="odaTrackCode" name="odaTrackCode"
                                           placeholder="请输入跟踪号" class="form-control">
                                </div>
                                <div class="form-group">
                                    <label>制单人</label>
                                    <input type="text" id="odrTakePerson" name="odrTakePerson"
                                           placeholder="请输入制单人" class="form-control"/>
                                </div>
                                <div class="form-group">
                                    <label>往来部门</label>
                                    <input type="text" id="odrDeptName"
                                           name="odrDeptName" class="form-control"
                                           placeholder="请输入往来部门">
                                </div>

                                <div class="form-group">
                                    <label>库位</label>
                                    <select id="odaWhiId" name="odaWhiId" class="form-control">
                                        <option value="">全部</option>
                                        <option th:each="type:${warInfo}" th:value="${type.whiId}"
                                                th:text="${type.whiName}"></option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label>
                                        单据类型
                                    </label>
                                    <select id="odrType" name="odrType" class="form-control">
                                        <option th:if="${odrType==1}" value="1">入库</option>
                                        <option th:if="${odrType==2}" value="2">出库</option>
                                    </select>
                                    <!--<select id="odrOutType" name="odrOutType" class="form-control">
                                        <option value="" selected="selected">全部</option>
                                        <option value="8">生产入库</option>
                                        <option value="1">采购入库</option>
                                        <option value="2">返料入库</option>
                                        <option value="3">调拨入库</option>
                                        <option value="4">领料出库</option>
                                        <option value="7">发货出库</option>
                                    </select>-->
                                </div>
                                <div class="form-group">
                                    <label>记账日期</label>
                                    <input type="text" class="form-control datepicker" id="startStorageDate"
                                           th:value="${#dates.format(startDate, 'yyyy-MM-dd')}"
                                           name="startStorageDate" readonly="readonly"/>
                                    <span>至</span>
                                    <input type="text" class="form-control datepicker" id="endStorageDate"
                                           th:value="${#dates.format(endDate, 'yyyy-MM-dd')}"
                                           name="endStorageDate" readonly="readonly"/>
                                </div>
                                <div class="form-group">
                                    <button type="button" class="btn btn-success" id="btn-search">搜索</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
                <div style="margin-left: 10px">
<!--                    <button type="button" id="btn_exportExcel"-->
<!--                            shiro:hasPermission="halwar:halwarquery:export"-->
<!--                            class="btn btn-primary" style="width: 82px">-->
<!--                        导出-->
<!--                    </button>-->
                    <img th:src="@{/img/downloadding.gif}" id="btn_tips" style="display: none"/>
                </div>
                <div class="box-body" style="padding-top: 0px; margin-top: -50px">
                    <table id="bootstrap-table"  style="word-break:break-all; word-wrap:break-all;"></table>
                </div>
            </div>
        </div>
    </div>
</section>
<div th:include="include :: footer"></div>

<script th:inline="javascript">

    var table;

    /**
     * 设置默认时间
     *
     */
    function getNowMonthDate() {
        var date = new Date();
        var year = date.getFullYear() + "";
        var month = (date.getMonth() + 1) + "";
        var date = date.getDate()+1;
        // 本月第一天日期
        var begin = year + "-" + month + "-1";
        // 本月最后一天日期
        var lastDateOfCurrentMonth = new Date(year,month,0);
        var end = year + "-" + month + "-" + lastDateOfCurrentMonth.getDate();
        // 当日
        var now = year + "-" + month + "-" + date;
        $("#startOdrMakeDate").val(begin);
        $("#endOdrMakeDate").val(now);
    }

    $(function () {
        //getNowMonthDate();
        /** 加载表格 */
        table = js.table.init({
            url: ctx + "half/halWarManage/inAndOutQuery/list",
            queryForm: "queryForm",
            paginationVAlign: 'both',
            columns: [
                {
                    title: '序号', field: 'odaId',
                    formatter: function (value, row, index, field) {
                        return index + 1;
                    }
                },
                {title: "单据类型", field: 'odrOutTypeName'},
                {title: "物料描述<br>（铝料类型）", field: 'odaMatName', width: '200'},
                {title: "图号<br>（铝料模具号）", field: 'odaDrawingCode'},
                //{title: "SAP<br>物料编码", field: 'odaSapCode'},
                {title: "数量", field: 'odaNum'},
                {title: "单位", field: 'odaUnit'},
                {title: "总重量<br>（KG）", field: 'odaWeight'},
                {title: "单价<br>（元）", field: 'odaPrice',
                    formatter: function (value, row, index) {
                        if (hasP("hhalinv:amount:view")) {
                            if (value == undefined || value == null || value == 0) {
                                return "--"
                            } else {
                                return Math.round(value*100)/100;
                            }
                        } else {
                            return '**';
                        }
                    }},
                {title: "金额<br>（元）", field: 'odaAmount',
                    formatter: function (value, row, index) {
                        if (hasP("hhalinv:amount:view")) {
                            if (value == undefined || value == null || value == 0) {
                                return "--"
                            } else {
                                return Math.round(value*100)/100;
                            }
                        } else {
                            return '**';
                        }
                    }},
                {title: "项目编号", field: 'odaProCode',width:'100'},
                {title: "项目名称", field: 'odaProName', width: '200'},
                {title: "跟踪号", field: 'odaTrackCode',width:'90'},
                {title: "库位", field: 'odaWhiIdName',width:'90'},
                {title: "记账日期", field: 'odaStorageDate',width:'100'},
                {title: "制单时间", field: 'odrDate',width:'100'},
                {title: "往来部门", field: 'odrDeptName'},
                {title: "制单人", field: 'odrTakePerson'},
                {
                    title: "操作", width: '50',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if (hasP("halwar:halwarquery:view")) {
                            actions.push('<a target="_blank" class="btn btn-info btn-xs" style="margin-right: 5px" href="' + ctx + 'half/halWarManage/inAndOutQuery/view?odrId=' + row.odrId + '&odrOutType=' + row.odrOutType + '&odaMatType=' + row.odaMatType + '" >查看</a>');
                        }
                        return actions.join('');
                    }
                }
            ]
        });
        // 搜索
        $("#btn-search").click(function () {
            js.table.search(table);
        });

        /**
         *@Description: 导出
         */
        $("#btn_exportExcel").click(function () {
            $("#btn_exportExcel").hide();
            $("#btn_tips").show();
            $("#queryForm").submit();
            setTimeout(function () {
                var actionVal = $("#queryForm").attr("action");
                $("#queryForm").removeAttr("action");
                $("#queryForm").attr("action", actionVal);
                $("#btn_tips").hide();
                $("#btn_exportExcel").show()
            }, 10000);
        });
    });

</script>
</body>
</html>